package com.noah.project.controller

import com.noah.project.global.Const
import com.noah.project.model.Note
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner

@RunWith(SpringRunner::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class NoteApiControllerTest {
    @Autowired
    lateinit var noteController: NoteApiController

    /*****************日记******************/
    @Test
    @Throws(Exception::class)
    fun addNote() {
        val note = Note(uid = 1, bid = 1, content = "开始写第二条日记")
        val reply = noteController.addNote(note, Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun deleteNote() {
        val reply = noteController.deleteNote(25, Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun updateNote() {
        val note = Note(nid = 25, content = "修改测试的消息2")
        val reply = noteController.updateNote(note, Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun getBookNotes() {
        val reply = noteController.getNoteList(1, System.currentTimeMillis(), Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun getAllNotes() {
        val reply = noteController.getNoteList(0, System.currentTimeMillis(), Const.TEST_TOKEN)
        println(reply.toString())
    }
}
